<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/3/9
 * Time: 17:01
 */

echo "<title>6-10 PHP中循环结构之do…while语句的运用优势举例</title>";
echo "<p style='text-align: center'><a href=\"index.php\"><font size=\"4\">目录</font></a></p>";
header("Content-type: text/html; charset=utf-8");
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";

//while例子
$sum = 0;
$num = mt_rand(1,6);//获取1至6的随机数，模拟掷骰子
$sum = $sum + $num;//前进步长
while($num==6){
    $num = mt_rand(1,6);//获取1至6的随机数，模拟掷骰子
    $num = $sum + $num;//前进部长
};
echo "do...while例子执行完毕，前进：".$sum."<br />";

//do...while例子
$sum = 0;
do{
    $num = mt_rand(1,6);//获取1至6的随机数，模拟掷骰子
    $sum = $sum + $num;//前进步长
}while($num==6);
echo "do...while例子执行完毕，前进：".$sum."<br />";















